package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ASUS
 * Date: 2023-11-13
 * Time: 16:32
 */
class Student {
    private String name;
    private int age;
    public static String classRoom = "116";

    public Student() {
        this.name = "xiaozhang";
        this.age = 19;
        System.out.println("不带参数的构造方法");
    }
    public Student(String name, int age){
        this.name =name;
        this.age = age;
        System.out.println("调用带两个参数的构造方法");
    }
    public String getName(){
        return name;
    }
    public void setName(String name){
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public void doClass(){
        System.out.println(this.name+"上课！");
    }
    public void print(){
        System.out.println("姓名："+this.name+" 年龄:" + this.age);
    }
}
public class Test1 {

    public static void main(String[] args) {
        Student student1 = new Student();
        Student student2 = new Student();
        student1 = new Student("xiaoluo",18);

        student2 = new Student("xiaofu",20);
        student1.print();
        student2.print();
        System.out.println(student1.classRoom);
    }
}
